<template>
	<view class="partner-pages" v-if="isLoad">
		<view class="partner-form pt-md">
			<view class="fill-base pl-lg pr-lg ">
				<view class="flex-between partner-item b-1px-b">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<text class="f-title">组局方式</text>
					</view>
					<view class="flex-center">
						<view class="flex-center" style="margin-left: 60rpx;" @tap="handleTpye(item.id)"
						v-for="(item,index) in [{title: '公开局', id: 1},{title: '私密局', id: 0}]" :key="index" 
						>
							<i class="iconfont" style="font-size: 20px;" :style="{color: form.is_open == item.id?primaryColor:'#BEC3CE'}"
							:class="[{'icon-radio-fill': form.is_open == item.id},{'icon-xuanze': form.is_open != item.id}]"></i>
							<text class="pl-sm f-desc text-bold">{{item.title}}</text>
						</view>
					</view>
				</view>
				<view class="flex-between partner-item b-1px-b" @tap="$util.goUrl({url: `/partner/pages/choose-classify`})">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<text class="f-title">组局类型</text>
					</view>
					<view class="flex-center">
						<text class="f-title text-bold pr-md">{{ form.type_id ? form.type_name : '选择组局类型'}}</text>
						<i class="iconfont icon-right text-bold" style="color: #9B9B9B;font-size: 13px;"></i>
					</view>
				</view>
				<view class="flex-between partner-item">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<text class="f-title">组局标题</text>
					</view>
					<view class="flex-center flex-1">
						<input v-model="form.title" class="partner-item-input flex-1 text-right" type="text" placeholder="请输入标题, 不超过10个字" maxlength="10"/>
					</view>
				</view>
			</view>
			<view class="fill-base mt-md pl-lg pr-lg pb-sm pt-sm">
				<view class="flex-y-center pt-lg pb-lg item-text">
					<i class="iconfont icon-required c-warning"></i>
					<text class="f-title c-title">组局封面<text class="c-caption">(建议尺寸:710*330)</text></text>
				</view>
				<view class="flex-between">
					<upload @upload="imgUpload" :imagelist="form.cover" imgtype="cover"
						text="上传图片" :imgsize="1">
					</upload>
				</view>
				<view class="flex-y-center pt-lg pb-lg item-text">
					<i class="iconfont icon-required c-warning "></i>
					<view class="f-title c-title">详情图<text class="c-caption">(建议尺寸:750*653)</text></view>
				</view>
				<view class="flex-between">
					<upload @upload="imgUpload" :imagelist="form.img" imgtype="img"
						text="上传图片" :imgsize="9">
					</upload>
				</view>
				<view class="flex-between pt-lg pb-lg" @tap="$util.goUrl({url: `/partner/pages/add-image-text`})">
					<text class="f-title c-title">图文详情</text>
					<i class="iconfont icon-right text-bold" style="color: #9B9B9B;font-size: 13px;"></i>
				</view>
			</view>
			
			<view class="fill-base mt-md pt-sm pl-lg pr-lg">
				<view class="pt-lg b-1px-b">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning "></i>
						<text class="f-title c-title">组局起止时间</text>
					</view>
					<view class="partner-item-date flex f-title c-title">
						<view class="partner-item-time f-min-title " :class="[{'c-title': form.start_time},{'c-disable':!form.start_time}]" @tap="showPicker('start_time')">{{form.start_time || '开始时间'}}</view>
						至
						<view class="partner-item-time f-min-title text-right" :class="[{'c-title': form.end_time},{'c-disable':!form.end_time}]" @tap="showPicker('end_time')">{{form.end_time || '结束时间'}}</view>
					</view>
				</view>
				<view class="b-1px-b partner-item flex-between" @tap="showPicker('join_end_time')">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<text class="f-title c-title">报名截止时间</text>
					</view>
					<view class="flex-center">
						<text class="f-title text-bold pr-md">{{form.join_end_time || '选择时间'}}</text>
						<i class="iconfont icon-right text-bold" style="color: #9B9B9B;font-size: 13px;"></i>
					</view>
				</view>
				<view class="b-1px-b partner-item flex-between">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<text class="f-title c-title">组局场所</text>
					</view>
					<view class="flex-center">
						<view class="f-paragraph flex-center ml-lg addr-type" v-for="(item,index) in ['选择场所','填写场所']" :key="index"
						:style="{color:addrType==index?'#FEFFFE':'#666',background:addrType==index?primaryColor:'#F4F4F4'}" @tap="handleAddr(index)">{{item}}</view>
					</view>
				</view>
				<view class="b-1px-b partner-item flex-between" v-if="addrType == 0" @tap="$util.goUrl({url: `/partner/pages/choose-store`})">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<text class="f-title c-title">场所门店</text>
					</view>
					<view class="flex-center">
						<text class="f-title text-bold pr-md max-500 ellipsis text-right">{{form.store_id ? form.store_name : '选择门店' }}</text>
						<i class="iconfont icon-right text-bold" style="color: #9B9B9B;font-size: 13px;"></i>
					</view>
				</view>
				<block v-if="addrType == 1">
					<view class="flex-between partner-item" @tap="toChooseLocation">
						<view class="flex-y-center item-text">
							<i class="iconfont icon-required c-warning"></i>
							<text class="f-title">地址</text>
						</view>
						<view class="flex-center">
							<text class="f-title text-bold pr-md max-500 ellipsis text-right">{{form.address || '请选择详细地址' }}</text>
							<i class="iconfont icon-right text-bold" style="color: #9B9B9B;font-size: 13px;"></i>
						</view>
					</view>
					<view class="flex-between partner-item b-1px-b">
						<view class="flex">
							<text class="f-title">详细地址</text>
						</view>
						<view class="flex-center flex-1">
							<input v-model="form.address_info" class="partner-item-input flex-1 text-right" type="text" placeholder="请输入详细地址"/>
						</view>
					</view>
				</block>
				<view class="flex-between partner-item b-1px-b">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<text class="f-title">局主手机号</text>
					</view>
					<view class="flex-center flex-1">
						<input v-model="form.phone" class="partner-item-input flex-1 text-right" type="text" placeholder="请输入局主手机号" />
					</view>
				</view>
				<view class="b-1px-b partner-item flex-between" @tap="$util.goUrl({url: `/partner/pages/choose-mix?type=enroll`})">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<text class="f-title c-title">报名字段</text>
					</view>
					<view class="flex-center">
						<text class="f-title text-bold pr-md max-470 ellipsis">{{form.field_text || '默认手机号,其余字段请选择'}}</text>
						<i class="iconfont icon-right text-bold" style="color: #9B9B9B;font-size: 13px;"></i>
					</view>
				</view>
				<view class="flex-between partner-item b-1px-b">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<text class="f-title">报名人数</text>
					</view>
					<view class="flex-center flex-1">
						<input v-model="form.sign_num" class="partner-item-input flex-1 text-right" type="text" placeholder="请输入报名人数" maxlength="10"/>
					</view>
				</view>
				<view class="partner-item flex-between" @tap="$util.goUrl({url: `/partner/pages/choose-mix?type=participants`})">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<text class="f-title c-title">设置参与人条件</text>
					</view>
					<view class="flex-center">
						<text class="f-title text-bold pr-md">{{ form.participants ? '已选择' : '请选择参与人条件'}}</text>
						<i class="iconfont icon-right text-bold" style="color: #9B9B9B;font-size: 13px;"></i>
					</view>
				</view>
			</view>
			<view class="mt-md fill-base pl-lg pr-lg">
				<view class="b-1px-b partner-item flex-between">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<view class="flex-y-center">
							<text class="f-title c-title">成员资料是否可见</text>
							<i class="iconfont iconchangjianwenti" style="margin-left: 2px;" @tap="handleTips(1)"></i>
						</view>
					</view>
					<view class="flex-center">
						<i class="iconfont" @tap="handleSwitch('show_user_info')" style="font-size: 50px;" :style="{color: form.show_user_info == 1?primaryColor: '#9B9B9B'}"
						:class="[{'icon-switch-on':form.show_user_info == 1},{'icon-switch':form.show_user_info == 0}]" ></i>
					</view>
				</view>
				<view class="b-1px-b partner-item flex-between">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<view class="flex-y-center">
							<text class="f-title c-title">是否要审核</text>
							<i class="iconfont iconchangjianwenti" style="margin-left: 2px;" @tap="handleTips(2)"></i>
						</view>
					</view>
					<view class="flex-center">
						<i class="iconfont" style="font-size: 50px;" @tap="handleSwitch('is_check')"
						:class="[{'icon-switch-on':form.is_check == 1},{'icon-switch':form.is_check == 0}]"  :style="{color: form.is_check == 1?primaryColor: '#9B9B9B'}"></i>
					</view>
				</view>
				<view class="b-1px-b partner-item flex-between" @tap="toShowMoneyType">
					<view class="flex-y-center item-text">
						<i class="iconfont icon-required c-warning"></i>
						<text class="f-title c-title">请客形式</text>
					</view>
					<view class="flex-center">
						<text class="f-title text-bold pr-md">{{moneyTypeList[form.money_type - 1].title}}</text>
						<i class="iconfont icon-right text-bold" style="color: #9B9B9B;font-size: 13px;"></i>
					</view>
				</view>
				<picker @change="pickerChange($event, 'sign')" :value="signIndex"
					:range="signTimeList" range-key="title">
					<view class="partner-item flex-between">
						<view class="flex-y-center item-text">
							<i class="iconfont icon-required c-warning"></i>
							<text class="f-title c-title">签到开始时间</text>
						</view>
						<view class="flex-center">
							<text class="f-title text-bold pr-md">{{ signIndex > -1 ? signTimeList[signIndex].title : '组局活动开始前多久签到'}}</text>
							<i class="iconfont icon-right text-bold" style="color: #9B9B9B;font-size: 13px;"></i>
						</view>
					</view>
				</picker>
			</view>
			<view class="pt-md pl-lg pr-lg flex-y-center" @tap.stop="handleAgreement">
				<i class="iconfont" :class="[{'icon-xuanze': !isAgreement},{'icon-xuanze-fill': isAgreement}]"
				:style="{color: isAgreement? primaryColor: '#D5D6DA'}"></i>
				<view class="f-paragraph c-paragraph" style="padding-left: 15rpx;">
					我已同意<text :style="{color: primaryColor}" @tap.stop="$util.goUrl({url: `/partner/pages/rule?type=partner_agreement`})">《免责协议》</text>与<text @tap.stop="$util.goUrl({url: `/partner/pages/rule?type=partner_instructions`})" :style="{color: primaryColor}">《组局须知》</text>
				</view>
			</view>
		</view>
		
		<uni-popup ref="show_tips" type="center" :maskClick="false">
			<view class="common-popup-content fill-base pd-lg radius-34">
				<view class="title">说明</view>
				<view class="f-desc c-title mt-lg">
					{{tips[tipsIndex]}}
				</view>
				<view class="button">
					<view @tap.stop="$refs.show_tips.close()" class="item-child c-base"
						:style="{background: primaryColor,color:'#fff'}">知道了</view>
				</view>
			</view>
		</uni-popup>
		<w-picker mode="date" :startYear="startYear" :endYear="startYear*1 + 10"
			:current="false" fields="minute"
			@confirm="pickerChange($event)" :disabled-after="false" ref="day" :themeColor="primaryColor"
			:visible.sync="showDate">
		</w-picker>
		
		<uni-popup ref="show_money_type" type="bottom" :maskClick="true">
			<view class="pl-lg pr-lg money-type fill-base">
				<view class="pt-lg pb-lg flex-between">
					<text class="c-paragraph" @tap="$refs.show_money_type.close()">取消</text>
					<text :style="{color: primaryColor}" @tap.stop="handleMoneyType(0,'check')">确定</text>
				</view>
				<view class="flex-between pb-lg pt-lg">
					<view class="flex-center" v-for="(item,index) in moneyTypeList" :key="index" @tap="handleMoneyType(index)">
						<i class="iconfont" :class="[{'icon-xuanze':moneyTypeIndex!=index},{'icon-xuanze-fill':moneyTypeIndex==index}]" 
						:style="{color: moneyTypeIndex==index ? primaryColor : '#D5D6DA' }"></i>
						<text class="text-bold" style="padding-left: 2px;">{{item.title}}</text>
					</view>
				</view>
				<view class="pb-lg pt-sm flex-y-center" v-if="moneyTypeIndex == 2">
					<text class="c-title">人均</text>
					<view class="radius-10 fill-body ml-sm mr-sm flex-cneter flex-1">
						<input v-model="form.join_price" class="flex-1 money-type-input pl-lg pr-lg text-center" type="text" placeholder="请输入" />
					</view>
					<text class="c-title">元</text>
				</view>
				<view class="c-caption f-desc pt-sm">
					提示：AA组局所产生的报名费待组局完成后，会自动进入“个人中心-余额”里，局主可自行提现至微信账户，需支付一定的手续费。
				</view>
				<view class="space-footer"></view>
			</view>
		</uni-popup>
		
		<uni-popup ref="show_payment" type="bottom" :maskClick="true" :zIndex="996">
			<view class="pl-lg pr-lg payment-box fill-base">
				<view class="flex-center pt-lg pb-lg b-1px-b f-title text-bold">支付方式</view>
				<view class="flex-between pt-lg pb-lg" :class="[{'b-1px-t': index > 0}]" @tap="handlePayment(index)"
				v-for="(item,index) in payList" :key="index" >
					<i class="iconfont mr-md" :class="item.icon" style="font-size: 26px;"></i>
					<view class="flex-y-center flex-1">
						<view class="f-title c-title">{{item.title}}</view>
						<view class="f-paragraph c-caption ml-md" v-if="item.id == 2">
							余额{{mineInfo.some_balance || 0}}元
						</view>
					</view>
					<i class="iconfont" :class="[{'icon-radio-fill': payInd == index}, {'icon-xuanze': payInd != index}]" 
					:style="{color:payInd == index ? primaryColor:'#999'}" style="font-size: 20px;"></i>
				</view>
				<view class="space-max-footer"></view>
			</view>
		</uni-popup>
		
		<view class="space-max-footer"></view>
		
		<fixed position="bottom" :zIndex="997">
			<view class="fill-base b-1px-t">
				<view class="submit-box flex-between">
					<view class="flex-cneter">
						<view class="" >
							<block v-if="detail.partner_money*1 > 0">
								<view class="flex-y-baseline" style="color: #FF4C88;line-height: 1;">
									<text class="f-little">¥</text>
									<text class="f-title text-bold">{{detail.partner_money}}</text>
								</view>
								<view class="f-icontext" style="color: #727272;">需支付发布费</view>
							</block>
							<view v-else class="text-bold" style="color: #FF4C88;">免费发布</view>
						</view>
					</view>
					<auth :needAuth="!userInfo || (userInfo && (!userInfo.phone || !userInfo.nickName))"
						:type="!userInfo.phone ? 'phone' : 'userInfo'" :must="isAuth" @go="submit" style="width: auto;">
						<view class="submit-btn c-base flex-center f-ms-title" :style="{background:primaryColor}">发布</view>
					</auth>
				</view>
				<view class="space-safe"></view>
			</view>
		</fixed>
		
		<!-- #ifdef MP-WEIXIN -->
		<user-privacy ref="user_privacy" :show="false"></user-privacy>
		<!-- #endif -->
		<!-- #ifdef APP-PLUS -->
		<longbingbing-app-check-auth type="location" ref="app_check_item"
			@confirm="toConfirmChooseLoca"></longbingbing-app-check-auth>
		<!-- #endif -->
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,
		mapMutations
	} from "vuex"
	export default {
		components: {},
		data() {
			return {
				isLoad: false,
				options: {},
				form: {
					is_open: 1,
					type_pid: '',
					type_id: '',
					type_name: '',
					title: '',
					cover: '',
					img: [],
					content: [],
					start_time: '',
					end_time: '',
					sign_start_minute: '',
					join_end_time: '',
					store_id: '',
					store_name: '',
					address: '',
					address_info: '',
					lat: '',
					lng: '',
					sign_num: '',
					participants: '',
					limit_age: 1,
					min_age: '',
					max_age: '',
					limit_sex: 0,
					show_user_info: 1,
					is_check: 1,
					money_type: 1, // 请客方式 1免费 2请客 3AA
					join_price: '',
					field: [],
					field_text: '',
					pay_model: '',
					phone: ''
				},
				rule: [
					{
						name: "type_id",
						checkType: "isNotNull",
						errorMsg: "请选择组局类型"
					}, 
					{
						name: "title",
						checkType: "isNotNull",
						errorMsg: "请输入组局标题",
						regType: 2
					},{
						name: "cover",
						checkType: "isNotNull",
						errorMsg: "请上传组局封面"
					},{
						name: "img",
						checkType: "isNotNull",
						errorMsg: "请上传详情图"
					},
					{
						name: "start_time",
						checkType: "isNotNull",
						errorMsg: "请选择组局开始时间"
					},
					{
						name: "end_time",
						checkType: "isNotNull",
						errorMsg: "请选择组局结束时间"
					},
					{
						name: "join_end_time",
						checkType: "isNotNull",
						errorMsg: "请选择报名截止时间"
					},
					{
						name: "store_id",
						checkType: "isNotNull",
						errorMsg: "请选择门店"
					},
					{
						name: "address",
						checkType: "isNotNull",
						errorMsg: "请选择地址"
					},
					// {
					// 	name: "field",
					// 	checkType: "isNotNull",
					// 	errorMsg: "请选择字段"
					// },
					{	name: "phone",
						checkType: "isMobile",
						errorMsg: "请输入局主手机号"
					},
					{
						name: "sign_num",
						checkType: "isNumber",
						errorMsg: "请输入报名人数",
						regType: 2
					},
					{
						name: "participants",
						checkType: "isNotNull",
						errorMsg: "请选择参与人条件",
					},
					{
						name: "sign_start_minute",
						checkType: "isNotNull",
						errorMsg: "请选择签到开始时间"
					}
				],
				moneyTypeList: [
					{title: '免费', id: 1},
					{title: '局主请客', id: 2},
					{title: 'AA组局', id: 3}
				],
				moneyTypeIndex: 0,
				signTimeList: [
					{title: '半小时', value: 30},
					{title: '1小时', value: 60},
					{title: '2小时', value: 120}
				],
				signIndex: -1,
				addrType: 0,
				lockTap: false,
				tips: {
					1: '设置开启，参与人报名成功后，可查看其他报名成员的报名资料以及昵称和头像，手机号除外，如选择不开启，则只能看到报名者的头像和昵称。',
					2: '成员报名，局主是否需要审核后才能报名'
				},
				tipsIndex: 1,
				startYear: '',
				showDate: false,
				dateType: '',
				isAgreement: false,
				detail: {},
				payList: [{
					id: 2,
					icon: 'iconqianbao c-balance',
					title: '账户余额'
				}],
				payInd: 0,
				isAuth: false
			}
		},
		computed: mapState({
			configInfo: state => state.config.configInfo,
			mineInfo: state => state.user.mineInfo,
			userInfo: state => state.user.userInfo,
		}),
		async onLoad(options) {
			this.$util.showLoading()
			await this.initIndex()
			if (this.scanRecordId) {
				this.updateScanRecord()
			}
			this.$util.setNavigationBarColor({
				bg: this.primaryColor
			})
			this.startYear = this.$util.formatTime(new Date().getTime(), 'YY')
			this.isLoad = true
			// #ifdef H5
			this.$jweixin.hideOptionMenu()
			// #endif
		},
		methods: {
			...mapActions(['getConfigInfo', 'getUserInfo', 'addScanRecord',
				'updateScanRecord', 'updateCommonOptions', 'getMineInfo'
			]),
			...mapMutations(['updateUserItem','updateOrderItem']),
			async initIndex(refresh = false) {
				// #ifdef H5
				if (!refresh) {
					this.$jweixin.hideOptionMenu()
				}
				// #endif
				await Promise.all([this.getUserInfo(), this.getConfigInfo({rules_status: 1}), this.getMineInfo()])
				let {
					app_wechat_pay = 0,
					alipay_status = 0,
					recharge_status = 0
				} = this.configInfo
				let weixinInd = this.payList.findIndex(item => {
					return item.id == 1
				})
				if (app_wechat_pay && weixinInd == -1) {
					this.payList.unshift({
						id: 1,
						icon: 'iconweixinzhifu1 c-wechat',
						title: '微信支付'
					})
				}
				
				// #ifndef MP-WEIXIN 
				let alipayInd = this.payList.findIndex(item => {
					return item.id == 3
				})
				if (alipay_status && alipayInd == -1) {
					this.payList.splice(this.payList.length - 1, 0, {
						id: 3,
						icon: 'icon-alipay c-alipay',
						title: '支付宝支付'
					})
				}
				// #endif
				
				if (!recharge_status) {
					let rechargeInd = this.payList.findIndex(item => {
						return item.id == 2
					})
					if (rechargeInd != -1) {
						this.payList.splice(rechargeInd, 1)
					}
				}
				
				let detail = await this.$api.partner.getConfig()
				this.detail = detail
				this.$util.setNavigationBarColor({
					bg: this.primaryColor
				})
				this.$util.hideAll()
			},
			initRefresh() {
				this.initIndex(true)
			},
			handleTpye(id){
				this.form.is_open = id
			},
			handleAddr(index){
				this.addrType = index
			},
			handleTips(index){
				this.tipsIndex = index
				this.$refs.show_tips.open()
			},
			handleSwitch(type){
				this.form[type] = this.form[type] == 0 ? 1 : 0
			},
			showPicker(type){
				this.dateType = type
				this.showDate = true
			},
			toShowMoneyType(){
				this.moneyTypeIndex = this.form.money_type - 1
				this.$refs.show_money_type.open()
			},
			handleAgreement(){
				this.isAgreement = !this.isAgreement
			},
			handleMoneyType(index, type = ''){
				console.log(index, type)
				if(type == 'check'){
					let {
						moneyTypeIndex = 0
					} = this
					let {
						join_price = ''
					} = this.form
					let validate = new this.$util.Validate();
					validate.add(join_price , {
						name: "join_price",
						checkType: "isFloatNum",
						errorMsg: "请输入AA组局金额",
						regType: 1,
						dotLen: 1
					});
					let message = validate.start();
					if (message && moneyTypeIndex == 2) {
						this.$util.showToast({
							title: message
						});
						return;
					}
					if(moneyTypeIndex !== 2){
						this.form.join_price = ''
					}
					this.form.money_type = moneyTypeIndex + 1
					this.$refs.show_money_type.close()
				}else{
					this.moneyTypeIndex = index
				}
			},
			pickerChange(e, type){
				console.log(e)
				if(type == 'sign'){
					let {
						value = 0
					} = e.detail
					this.signIndex = value
					this.form.sign_start_minute = this.signTimeList[value].value
				}else{
					this.form[this.dateType] = e.result
				}
			},
			handlePayment(index){
				let {
					partner_money = 0
				} = this.detail
				let {
					some_balance: balance = 0
				} = this.mineInfo
				if(partner_money*1 > balance*1 && this.payList[index].id == 2){
					this.$util.showToast({
						title: `账户余额不足`
					})
					return
				}
				this.payInd = index
			},
			imgUpload(e) {
				let {
					imagelist,
					imgtype
				} = e;
				this.form[imgtype] = imagelist;
			},
			// 选择地区
			async toChooseLocation() {
				// #ifdef APP-PLUS
				if (plus.os.name == 'Android' && plus.navigator.checkPermission(
						'android.permission.ACCESS_FINE_LOCATION') ===
					'undetermined') {
					this.$refs.app_check_item.open()
				} else {
					this.toConfirmChooseLoca()
				}
				// #endif
				// #ifndef APP-PLUS
				this.toConfirmChooseLoca()
				// #endif
			},
			async toConfirmChooseLoca() {
				// #ifdef MP-WEIXIN
				let privacyCheck = this.$refs.user_privacy.check()
				if (privacyCheck) {
					this.$refs.user_privacy.open()
					return
				}
				// #endif
				let {
					lat,
					lng,
					name,
					address
				} = await this.$util.chooseLocation()
				if (!lat && !lng) return
				if (name && !address) {
					this.$util.showToast({
						title: `请选择具体的地址`
					})
					return
				}
				// let {
				// 	province,
				// 	city,
				// 	area
				// } = await this.$util.getCityAddr(address)
			
				let form = Object.assign({}, this.form, {
					lat,
					lng,
					address
				})
				this.form = form
			},
			//表单验证
			validate(param) {
				let validate = new this.$util.Validate();
				this.rule.map(item => {
					let {
						name,
					} = item
					console.log(item)
					if(name === 'start_time' && param.start_time && new Date(param.start_time).getTime() < new Date().getTime()){
						item.errorMsg = "组局的开始时间不能小于当前时间"
						validate.add('', item);
					}else if(name === 'end_time' && param.end_time && param.end_time < param.start_time){
						item.errorMsg = "组局的结束时间不能小于开始时间"
						validate.add('', item);
					}else if(name === 'join_end_time' && param.join_end_time && param.join_end_time >= param.start_time){
						item.errorMsg = "报名截止时间不能大于等于组局的开始时间"
						validate.add('', item);
					}else if(name === 'store_id' && this.addrType == 1){
						
					}else if(name === 'address' && this.addrType == 0){
						
					}else{
						validate.add(param[name], item);
					}
				})
				let message = validate.start();
				return message;
			},
			async submit() {
				let param = this.$util.deepCopy(this.form)
				let msg = this.validate(param);
				if (msg) {
					this.$util.showToast({
						title: msg
					});
					return;
				}
				
				if(!this.isAgreement){
					this.$util.showToast({
						title: `请勾选《免责协议》与《组局须知》`
					});
					return
				}
				
				if(!this.$refs.show_payment.showPopup){
					this.$refs.show_payment.open()
					return
				}
				
				let {
					id: pay_model
				} = this.payList[this.payInd]
				
				let {
					partner_money = 0
				} = this.detail
				let {
					some_balance: balance = 0
				} = this.mineInfo
				if(partner_money*1 > balance*1 && pay_model == 2){
					this.$util.showToast({
						title: `账户余额不足`
					})
					return
				}
				this.isAuth = true
				
				
				param.img = param.img.map(src => {
					return src.path
				})
				param.cover = param.cover[0].path
				
				param.pay_model = pay_model
				param.start_time = this.$util.DateToUnix(param.start_time)
				param.join_end_time = this.$util.DateToUnix(param.join_end_time)
				param.end_time = this.$util.DateToUnix(param.end_time)
				
				if(this.addrType == 1){
					param.store_id = 0
				}else{
					param.address = ''
					param.address_info = ''
				}
				
				delete param.type_name
				delete param.store_name
				delete param.participants
				delete param.field_text
				if (this.lockTap) return
				this.lockTap = true
				this.$util.showLoading()
				try {
					let {
						pay_list,
						order_id = 0
					} = await this.$api.partner.payOrder(param)
					this.$util.hideAll()
					if(pay_list){
						if (pay_model == 3) {
							pay_list = {
								orderInfo: pay_list,
								provider: 'alipay'
							}
						}
						// #ifdef H5
						if (pay_model == 3) {
							let {
								autograph
							} = this
							let alipay_params = `?autograph=${autograph}&id=${order_id}&aliptype=7`
							pay_list = Object.assign({}, pay_list, {
								order_id,
								page_url: `/pages/partner`,
								alipay_params
							})
							this.updateOrderItem({
								key: 'alipayOrderParams',
								val: pay_list
							})
							this.$util.goUrl({
								url: `/user/pages/alipay-result${alipay_params}`,
								openType: `redirectTo`
							})
							return
						}
						// #endif
						try {
							await this.$util.pay(pay_list)
							this.$util.showToast({
								title: `支付成功`
							})
							
							// this.initRefresh()
							setTimeout(()=>{
								this.lockTap = false;
								this.$util.back()
								this.$util.goUrl({
									url: 1,
									openType: `navigateBack`
								})
							},1000)
						} catch (e) {
							this.$util.showToast({
								title: `支付失败`
							})
							this.lockTap = false;
							return;
						}
					}
					// 余额支付/零元支付
					this.$util.showToast({
						title: `支付成功`
					})
					setTimeout(() => {
						this.lockTap = false
						this.$util.back()
						this.$util.goUrl({
							url: 1,
							openType: `navigateBack`
						})
					}, 1000)				
				} catch (e) {
					setTimeout(() => {
						this.lockTap = false
						this.$util.hideAll()
					}, 2000)
				}

			}
		}
	}
</script>


<style lang="scss">
	.partner-pages{
		.partner-item{
			height: 128rpx;
			.partner-item-input{
				height: 128rpx;
			}
		}
		.partner-item-date{
			padding: 50rpx 0;
		}
		.partner-item-time{
			min-width: 260rpx;
		}
		.addr-type{
			width: 150rpx;
			height: 63rpx;
			border-radius: 63rpx;
		}
		
		.money-type{
			border-radius: 30rpx 30rpx 0 0;
			height: 520rpx;
			.money-type-input{
				height: 80rpx;
			}
		}
		.submit-box{
			height: 120rpx;
			padding: 0 30rpx 0 66rpx;
			.submit-btn{
				width: 283rpx;
				height: 90rpx;
				border-radius: 90rpx;
			}
		}
		
		.payment-box{
			border-radius: 30rpx 30rpx 0 0;
		}
		
		.item-text{
			line-height: normal;
		}
	}
</style>